package com.xiaodimall.beforesys.controller;

import com.xiaodimall.beforesys.service.PayService;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @author wyc
 * @description
 * @ClassName payPageController
 * @date 2022/11/30 18:34
 */
@Controller
public class payPageController {


    //注入支付业务层对象
   @Resource
   PayService payService;

    @ApiOperation(value = "去选着支付方式页面")
    @GetMapping("/selectPayType")
    public String selectPayType(HttpServletRequest request,
                                @RequestParam("orderNo") String orderNo,
                                HttpSession httpSession) {
        return payService.toPayTypePage(request,orderNo,httpSession);
    }

    @ApiOperation(value = "选择支付方式进行支付")
    @GetMapping("/payPage")
    @ResponseBody
    public String payOrder(HttpSession session,
                           @RequestParam("orderNo") String orderNo,
                           @RequestParam("payType") int payType) {
        return payService.choosePayService(session,orderNo,payType);
    }

}
